package com.iyue.util.file;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.httpclient.methods.multipart.PartSource;

public class FileItemPartSource implements PartSource {
	private String filename;
	private FileItem fileitem;

	public FileItemPartSource(String name, FileItem item) {
		this.fileitem = item;
		this.filename = name;
	}

	@Override
	public InputStream createInputStream() throws IOException {
		return fileitem.getInputStream();
	}

	@Override
	public String getFileName() {
		return filename;
	}

	@Override
	public long getLength() {
		return fileitem.getSize();
	}

}
